package com.sinoglobal.dumping.dumplingdialog;

import android.view.View;

import com.sinoglobal.dumping.view.Dumpling_GetMoneyDialog;

/**
 * Created by KeZhuang on 2016/1/14.
 */
public class DumplingCouponDialog extends DumplingDialogHelper implements DumplingIDialogFactory {


    @Override
    public Dumpling_GetMoneyDialog makeDialog(DumplingDialogHelper helper) {
        super.setValue(helper);
        int cardType = Integer.parseInt(getDumplingVo().getCardType());
        String url = getDumplingVo().getCardUrl();
        Dumpling_GetMoneyDialog.Builder builder = getBuilder();
        builder
            .setType(Dumpling_GetMoneyDialog.TYPE_COUPON)
            .setBtnLeftVISIBLE(View.VISIBLE)
            .setBtnRightVISIBLE(View.VISIBLE)
            .setBtnLeftText(getLogin() ? "马上分享" : "去领取")
            .setBtnRightText("继续捞")
            .setCouponSize(cardType == 1 ? Dumpling_GetMoneyDialog.COUPONSIZE_SMALL : Dumpling_GetMoneyDialog.COUPONSIZE_BIG)
            .setCoreField(url);
        if(getCount()==0){
            builder.setBtnLeftVISIBLE(getLogin() ? View.VISIBLE : View.GONE)
                    .setBtnRightVISIBLE(View.VISIBLE)
                    .setBtnLeftText(getLogin() ? "马上分享" : "")
                    .setBtnRightText(getLogin() ? "去钱包" : "去领取")
                    .setToast(getLogin() ? (getShare() < 2 && getMoney() > 0.0 ? "马上分享,再得一次机会" : "机会用完啦") : "马上领钱,再得一次机会");
        }
        builder.setOnClick(new Dumpling_GetMoneyDialog.GetMoneyOnSureClick() {
                @Override
                public void onCloseClick() {

                }

                @Override
                public void onBtnLeftClick() {
                    leftButtonClick();
                }

                @Override
                public void onBtnRightClick() {
                    if(getCount()==0){
                        if(getLogin()){
                            goWallet();
                        }else{
                            getDumpling(getContext());
                        }
                    }else if(getLogin()){
                        loginAcquireDumpling();
                    }else{
                        acquireDumpling();
                    }
                }
            });
        return builder.builder();
    }
}
